<?php 
/**
 * ... ...
 * ... ...
 *
 */ 



// 载入父 类 
//<<[UnmodifiableBlock.Start]::Include Parent Class::>>//
JCAT_Package::ImportClass('JCAT_UIGtkCtrlTree',JCAT::PACKAGE_UICTRLGTK) ;
//<<[UnmodifiableBlock.End]::Include Parent Class::>>//

// 载入所需的 数据校验器 类 
//<<[UnmodifiableBlock.Start]::Include Data Verifier Class::>>//

//<<[UnmodifiableBlock.End]::Include Data Verifier Class::>>//

/**
 * JCAT_UIGtkCtrlTree 类型UI控件 TreeJCATMVCObject 
 * 
 * @access	public
 * @author	由 JeCat PHP Toolbox 产生 
 */
class TreeJCATMVCObject 
	//<<[UnmodifiableBlock.Start]::Extends::>>//
	extends JCAT_UIGtkCtrlTree 
	//<<[UnmodifiableBlock.End]::Extends::>>//
{
	/**
	 * TreeJCATMVCObject类 的 构造函数 
	 * 
	 * @access	public
	 * @return	void
	 */
	public function TreeJCATMVCObject( $bControllerOperation=false )
	{
		// 初始化 父类 
		//<<[UnmodifiableBlock.Start]::Init Parent Class::>>//
		$this->JCAT_UIGtkCtrlTree(__CLASS__,JCAT_Language::Sentence("*"),'TreeJCATMVCObject') ; 
		//<<[UnmodifiableBlock.End]::Init Parent Class::>>//

		// 创建并载入 数据校验器 
		//<<[UnmodifiableBlock.Start]::Data Verifier::>>//

		//<<[UnmodifiableBlock.End]::Data Verifier::>>//


		// 在此添加 初始化 代码 
		// TODO ... ...
		$this->EnableUICtrlChangedEvent(false) ;
		
		$this->bControllerOperation = $bControllerOperation ;

	}
	
	/**
	 * 创建一个  GtkTreeModel 模型  
	 * 
	 * @access	public
	 * @return	void
	 */
	public function CreateModel()
	{
		//<<[UnmodifiableBlock.Start]::Create Model::>>//
		$aModel = new GtkTreeStore(
			Gtk::TYPE_STRING
			, Gtk::TYPE_STRING
			, Gtk::TYPE_STRING
			, Gtk::TYPE_STRING
			, Gtk::TYPE_STRING
			, Gtk::TYPE_BOOLEAN
			, Gtk::TYPE_STRING
			) ;
		//<<[UnmodifiableBlock.End]::Create Model::>>//
		
		// 在此添加代码  
		// TODO ... ...
		
		return $aModel ;
	}
	
	/**
	 * 初始化  GtkTreeView 的列  
	 * 
	 * @access	public
	 * @return	void
	 */
	public function InitializeColumns()
	{
		// 取得视图 
		$wndTreeView = $this->GetMainWidget() ;
		JCAT_ASSERT::ASSERT_INSTANCE($wndTreeView,'GtkTreeView',
					JCAT_Language::SentenceEx('UI控件“%”的主窗体尚未创建，在正常情况下  InitializeColumns()不应该被直接调用，UI控件的主窗体在创建之时，会自动调用此方法。','JCAT',null,$this->GetName())) ;

		// 设置 视图上的 各列 
		//<<[UnmodifiableBlock.Start]::Setting Columns::>>//
		// 视图列： 类型
		$aRenderForColumn0 = new GtkCellRendererText() ;
		$aRenderForColumn0->set_property('editable',false) ;
		$wndColumn0 = new GtkTreeViewColumn(JCAT_Language::Sentence(' 类型'),$aRenderForColumn0,'text',self::CLM_TYPE) ;
		$wndColumn0->set_visible(false) ;
		$wndTreeView->append_column($wndColumn0) ;

		// 视图列：图标
		$aRenderForColumn1 = new GtkCellRendererPixbuf() ;
		$wndColumn1 = new GtkTreeViewColumn(JCAT_Language::Sentence('图标'),$aRenderForColumn1,'pixbuf',self::CLM_ICON) ;
		$wndColumn1->set_cell_data_func($aRenderForColumn1,array($this,'OnRenderPixbuf'),self::CLM_ICON) ;
		$wndTreeView->append_column($wndColumn1) ;

		// 视图列：名称
		$aRenderForColumn2 = new GtkCellRendererText() ;
		$aRenderForColumn2->set_property('editable',false) ;
		$wndColumn2 = new GtkTreeViewColumn(JCAT_Language::Sentence('名称'),$aRenderForColumn2,'text',self::CLM_NAME) ;
		$wndTreeView->append_column($wndColumn2) ;

		// 视图列：文档关联(视图)
		$aRenderForColumn3 = new GtkCellRendererCombo() ;
		$aRenderForColumn3->set_property('has-entry',false) ;
		$aRenderForColumn3->set_property('editable',true) ;
		$aRenderForColumn3->connect('edited',array($this,'OnTextEdit'),self::CLM_DOCNAME) ;
		$wndColumn3 = new GtkTreeViewColumn(JCAT_Language::Sentence('文档关联(视图)'),$aRenderForColumn3,'text',self::CLM_DOCNAME) ;
		$wndTreeView->append_column($wndColumn3) ;

		// 视图列：全局名称
		$aRenderForColumn4 = new GtkCellRendererText() ;
		$aRenderForColumn4->set_property('editable',true) ;
		$aRenderForColumn4->connect('edited',array($this,'OnTextEdit'),self::CLM_GLOBAL_NAME) ;
		$wndColumn4 = new GtkTreeViewColumn(JCAT_Language::Sentence('全局名称'),$aRenderForColumn4,'text',self::CLM_GLOBAL_NAME) ;
		$wndTreeView->append_column($wndColumn4) ;

		// 视图列：活动
		$aRenderForColumn5 = new GtkCellRendererToggle() ;
		$aRenderForColumn5->set_property('activatable',true) ;
		$aRenderForColumn5->connect('toggled',array($this,'OnActiveToggled'),self::CLM_ACTIVE) ;
		$wndColumn5 = new GtkTreeViewColumn(JCAT_Language::Sentence('活动'),$aRenderForColumn5,'active',self::CLM_ACTIVE) ;
		$wndTreeView->append_column($wndColumn5) ;

		// 视图列：路径
		$aRenderForColumn6 = new GtkCellRendererText() ;
		$aRenderForColumn6->set_property('editable',false) ;
		$wndColumn6 = new GtkTreeViewColumn(JCAT_Language::Sentence('路径'),$aRenderForColumn6,'text',self::CLM_PATH) ;
		$wndTreeView->append_column($wndColumn6) ;
		//<<[UnmodifiableBlock.End]::Setting Columns::>>//
		

		// 在此添加 代码 
		// TODO ... ...
		
		
		if( !$this->bControllerOperation )
		{
			$wndColumn = $this->GetColumn(self::CLM_ACTIVE) ;
			$wndColumn->set_visible(false) ;
			$wndColumn = $this->GetColumn(self::CLM_GLOBAL_NAME) ;
			$wndColumn->set_visible(false) ;
			$wndColumn = $this->GetColumn(self::CLM_DOCNAME) ;
			$wndColumn->set_visible(false) ;
		}
	}

	
	
	/**
	 * 重載 GetItemData() , 只保存 一级 Item
	 * 
	 * @access	public
	 * @param 	$nParentItem=null	GtkTreeIter		上级 Item
	 * @param 	$sChildElementKey	string  		下级 Item 的元素键名
	 * @return	array
	 */
	public function GetItemData( $nParentItem=null, $sChildElementKey='children' )
	{
		$aModel = $this->GetGtkModel() ;
		JCAT_ASSERT::ASSERT_INSTANCE($aModel,'GtkTreeModel');
		
		$arrRet = array() ;
		
		$aIterator = new JCAT_GtkTreeItemIterator($aModel,$nParentItem,0) ;
		while( !$aIterator->IsDone() )
		{
			$aItem = $aIterator->Current() ;	
			$arrItem = array() ;
			
			$sItemPath = $aModel->get_path($aItem) ;
			
			// 各个 Column 上的值
			$nColumnNum = $aModel->get_n_columns() ;
			for ($nIdx=0;$nIdx<$nColumnNum;$nIdx++)
			{
				$arrItem[$nIdx] = $aModel->get_value($aItem,$nIdx) ;
			}
						
			$arrRet[] = $arrItem ;
			
			// 下一个
			$aIterator->Next() ;
		}
		
		return $arrRet ;
	}
	

	// 为 视图的列 定义常量 
	//<<[UnmodifiableBlock.Start]::Define Column Consts::>>//
	const CLM_TYPE = 0 ;
	const CLM_ICON = 1 ;
	const CLM_NAME = 2 ;
	const CLM_DOCNAME = 3 ;
	const CLM_GLOBAL_NAME = 4 ;
	const CLM_ACTIVE = 5 ;
	const CLM_PATH = 6 ;
	//<<[UnmodifiableBlock.End]::Define Column Consts::>>//
	
	
	private $bControllerOperation ;
}






?><?
/**
 * [注意!!]
 *	以下内容由 JCAT PHP Toolbox 自动维护，手动更改的内容会被 JCAT PHP Toolbox 抹除，
 *	同时还可能破坏格式，导致 JCAT PHP Toolbox 无法正常读取。
 */
/*<<[UnmodifiableBlock.Start]::Coder Dialog Data::>>&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&//
<<{{DocumentClass:UICtrlGtkTreeDoc}}>>
eCVEQSVBNSU5NF9rJUQzUCUxOCVDNiVFRiUwNSVCRiU4MyV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